package com.yupi.springbootinit.bizmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.yupi.springbootinit.bizmq.BiMqConstant.BI_EXCHANGE_NAME;
import static com.yupi.springbootinit.bizmq.BiMqConstant.BI_ROUTING_KEY;

/**
 * @version 1.0
 * @Author moresuo
 * @Date 2024/3/6 22:53
 * @注释 消息生产者代码
 */
@Component
public class BiMessageProducer {
    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息的方法
     * @param message 消息
     */
    public void sendMessage(String message){
        rabbitTemplate.convertAndSend(BI_EXCHANGE_NAME, BI_ROUTING_KEY, message);
    }
}
